<!DOCTYPE html>
<html ng-app="domeApp">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>登录</title>
		<style>.error{color:red;}</style>
    </head>
    <body>
    	<div>
    		用户名：<input id="username" type="text" placeholder="请输入用户"><br><br>
    		密码：<input id="password" type="password" placeholder="请输入密码"><br>
    		<button id="login">登录</button>
            <button id="ldap_login">LDAP登录</button>
    	</div>
    	<script type="text/javascript" src="../anon/js/jquery-1.8.3.min.js"></script>
    	<script type="text/javascript">
    	$(function() {
    		$('#login').bind('click', function(event) {
    			/* Act on the event */
    			var username = $('#username').val(),
    				password = $('#password').val();
    			var data = {
    				username: username,
    				password: password,
                    loginType: 'USER'
    			};
    			$.ajax({
    				type: 'post',
    				url: '/api/user/login',
    				data: JSON.stringify(data),
					contentType: "application/json; charset=utf-8",
    				dataType: 'json',
    				success: function() {
						window.location.href="index.htm"
    				},
    				erroe: function() {
    					alert('发送失败');
    				}
    			});
    		});
    	});
        $(function() {
            $('#ldap_login').bind('click', function(event) {
                /* Act on the event */
                var username = $('#username').val(),
                        password = $('#password').val();
                var data = {
                    username: username,
                    password: password,
                    loginType: 'LDAP'
                };
                $.ajax({
                    type: 'post',
                    url: '/api/user/login',
                    data: JSON.stringify(data),
                    contentType: "application/json; charset=utf-8",
                    dataType: 'json',
                    success: function() {
                        window.location.href="index.htm"
                    },
                    erroe: function() {
                        alert('发送失败');
                    }
                });
            });
        });
    	</script>
    </body>
</html>